#!/bin/bash

function genMunu {
	clear
	echo
	echo -e "\t\t\tSys Admin Menu\n"
	echo -e "\t1. Display disk space"
	echo -e "\t2. Display logged on users"
	echo -e "\t3. Display memory usage"
	echo -e "\t0. Exit menu\n\n"
	echo -en "\t\tEnter option: "
	read -n 1 option
}

genMunu

while [[ 1 ]]; do
	genMunu
	case $option in
	0 )
		exit
		echo "Bye"
	;;
	1 )
		echo "Display disk space"
		dfinfo=$(df)
		cat < dfinfo
		# echo -e $dfinfo
	;;
	2 )
		echo "Display logged on users: $USER"
	;;
	3 )
		echo "Display memory usage"
	;;
	h )
		genMunu
	;;
	* )
		echo "Wrong!!"
	;;
	esac

	echo
	echo -en "\n\n\tHit any key to continue"
	read -n 1 line

done



# # 使用select菜单
# function diskspace {
# 	clear
# 	df -k
# }
# function whoseon {
# 	clear
# 	who
# }
# function memusage {
# 	clear
# 	cat /proc/meminfo
# }

# PS3="Enter option: "
# select option in "Display disk space" "Display logged on users" "Display memory usage" "Exit program"
# do
# case $option in
# 	"Exit program")
# 		break ;;
# 	"Display disk space")
# 		diskspace ;;
# 	"Display logged on users")
# 		whoseon ;;
# 	"Display memory usage")
# 		memusage ;;
# 	*)
# 		clear
# 		echo "Sorry, wrong selection";;
# esac
# done

# clear

